(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define([], factory) :
  global.HtmlString = factory();
}(this, function () { 'use strict';

  var HtmlString = function(body) {
    return new htmlContent({
      body: body
    })
  }

  function htmlContent(contentObj) {
    this.headLink = contentObj.headLink || [];
    this.headScript = contentObj.headScript || [];
    this._style = contentObj.style || '';
    this._script = contentObj.script || '';
    this._body = contentObj.body || '';
    return this;
  }

  htmlContent.prototype = {
    constructor: htmlContent,
    toString: function() {
      var html = '<!DOCTYPE html>\n';
      html += '<head>\n';

      html += '<meta charset="utf-8">\n';
      html += '<meta http-equiv="X-UA-Compatible" content="IE=edge">\n';
      html += '<meta name="description" content="">\n';
      html += '<meta name="viewport" content="width=device-width, initial-scale=1">\n';
      html += '<title></title>\n';

      for (var i = 0; i < this.headLink.length; i++) {
        html += link(this.headLink[i]) + '\n';
      }

      for (var i = 0; i < this.headScript.length; i++) {
        html += script(this.headScript[i] + '\n');
      }

      html += '<style>' + this._style + '</style>' + '\n';
      html += '</head>\n';
      html += '<body>\n';
      html += this._body + '\n';
      html += this._script + '\n';

      html += '</body>\n';
      html += '</html>\n';

      return html;

    },
    style: function(style) {
      this._style += style;
      return this;
    },
    css: function(css) {
      this.headLink.push(css);
      return this;
    },
    script: function(script) {
      this.headScript.push(script);
      return this;
    },
    body: function(body) {
      this._body += body;
      return this;
    }
  }

  function link(css) {
    return '<link rel="stylesheet" href="' + css + '">';
  }

  function script(script) {
    return '<script src="' + script + '"></script>'
  }

  return HtmlString;
}))